Add PlaceholderTextFocused key in PLACEHOLDER property 57/139457/2
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Wed, 19 Jul 2017 04:36:46 +0000 (13:36 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 20 Jul 2017 09:27:47 +0000 (18:27 +0900)
 - PLACEHOLDER property is MAP type.

Change-Id: I4694860c892c35ef112fab646b72258de538c563
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h
dali-toolkit/devel-api/controls/text-controls/text-field-devel.h
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller.cpp
dali-toolkit/internal/text/text-controller.h

index 70e229c..d884271 100644 (file)
@@ -26,7 +26,6 @@
 #include <dali/integration-api/events/pan-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <dali/integration-api/events/pan-gesture-event.h>
 #include <dali-toolkit-test-suite-utils.h>
 #include <dali-toolkit/dali-toolkit.h>
-#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
 
 using namespace Dali;
 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
 
 using namespace Dali;
@@ -767,12 +766,6 @@ int UtcDaliTextEditorSetPropertyP(void)
   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
 
   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
   DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
 
-  // Check placeholder text properties when focused.
-  editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
-  editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
-  DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
-  DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
-
   // Check placeholder text's color property.
   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
   // Check placeholder text's color property.
   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
@@ -786,6 +779,7 @@ int UtcDaliTextEditorSetPropertyP(void)
   Property::Map placeholderPixelSizeMapGet;
   Property::Map placeholderFontstyleMap;
   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
   Property::Map placeholderPixelSizeMapGet;
   Property::Map placeholderFontstyleMap;
   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+  placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
@@ -802,6 +796,7 @@ int UtcDaliTextEditorSetPropertyP(void)
   Property::Map placeholderMapSet;
   Property::Map placeholderMapGet;
   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
   Property::Map placeholderMapSet;
   Property::Map placeholderMapGet;
   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+  placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
   placeholderMapSet["placeholderColor"] = Color::RED;
   placeholderMapSet["placeholderFontFamily"] = "Arial";
   placeholderMapSet["placeholderPointSize"] = 12.0f;
   placeholderMapSet["placeholderColor"] = Color::RED;
   placeholderMapSet["placeholderFontFamily"] = "Arial";
   placeholderMapSet["placeholderPointSize"] = 12.0f;
index b1f4d07..6c7e8d1 100644 (file)
@@ -860,6 +860,7 @@ int UtcDaliTextFieldSetPropertyP(void)
   Property::Map placeholderPixelSizeMapGet;
   Property::Map placeholderFontstyleMap;
   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
   Property::Map placeholderPixelSizeMapGet;
   Property::Map placeholderFontstyleMap;
   placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
+  placeholderPixelSizeMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
   placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
   placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
   placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
@@ -876,6 +877,7 @@ int UtcDaliTextFieldSetPropertyP(void)
   Property::Map placeholderMapSet;
   Property::Map placeholderMapGet;
   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
   Property::Map placeholderMapSet;
   Property::Map placeholderMapGet;
   placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
+  placeholderMapSet["placeholderTextFocused"] = "Setting Placeholder Text Focused";
   placeholderMapSet["placeholderColor"] = Color::RED;
   placeholderMapSet["placeholderFontFamily"] = "Arial";
   placeholderMapSet["placeholderPointSize"] = 12.0f;
   placeholderMapSet["placeholderColor"] = Color::RED;
   placeholderMapSet["placeholderFontFamily"] = "Arial";
   placeholderMapSet["placeholderPointSize"] = 12.0f;
index e09207c..b2dc43a 100644 (file)
@@ -145,14 +145,15 @@ namespace Property
        * @code
        *   Property::Map propertyMap;
        *   propertyMap["placeholderText"] = "Setting Placeholder Text";
        * @code
        *   Property::Map propertyMap;
        *   propertyMap["placeholderText"] = "Setting Placeholder Text";
+       *   propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
        *   propertyMap["placeholderColor"] = Color::RED;
        *   propertyMap["placeholderFontFamily"] = "Arial";
        *   propertyMap["placeholderPointSize"] = 12.0f;
        *
        *   Property::Map fontStyleMap;
        *   propertyMap["placeholderColor"] = Color::RED;
        *   propertyMap["placeholderFontFamily"] = "Arial";
        *   propertyMap["placeholderPointSize"] = 12.0f;
        *
        *   Property::Map fontStyleMap;
-       *   fontstyleMap.Insert( "weight", "bold" );
-       *   fontstyleMap.Insert( "width", "condensed" );
-       *   fontstyleMap.Insert( "slant", "italic" );
+       *   fontStyleMap.Insert( "weight", "bold" );
+       *   fontStyleMap.Insert( "width", "condensed" );
+       *   fontStyleMap.Insert( "slant", "italic" );
        *   propertyMap["placeholderFontStyle"] = fontStyleMap;
        *
        *   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap );
        *   propertyMap["placeholderFontStyle"] = fontStyleMap;
        *
        *   editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, propertyMap );
index b678508..9ff0b2c 100644 (file)
@@ -111,14 +111,15 @@ namespace Property
        * @code
        *   Property::Map propertyMap;
        *   propertyMap["placeholderText"] = "Setting Placeholder Text";
        * @code
        *   Property::Map propertyMap;
        *   propertyMap["placeholderText"] = "Setting Placeholder Text";
+       *   propertyMap["placeholderTextFocused"] = "Setting Placeholder Text Focused";
        *   propertyMap["placeholderColor"] = Color::RED;
        *   propertyMap["placeholderFontFamily"] = "Arial";
        *   propertyMap["placeholderPointSize"] = 12.0f;
        *
        *   Property::Map fontStyleMap;
        *   propertyMap["placeholderColor"] = Color::RED;
        *   propertyMap["placeholderFontFamily"] = "Arial";
        *   propertyMap["placeholderPointSize"] = 12.0f;
        *
        *   Property::Map fontStyleMap;
-       *   fontstyleMap.Insert( "weight", "bold" );
-       *   fontstyleMap.Insert( "width", "condensed" );
-       *   fontstyleMap.Insert( "slant", "italic" );
+       *   fontStyleMap.Insert( "weight", "bold" );
+       *   fontStyleMap.Insert( "width", "condensed" );
+       *   fontStyleMap.Insert( "slant", "italic" );
        *   propertyMap["placeholderFontStyle"] = fontStyleMap;
        *
        *   field.SetProperty( DevelTextField::Property::PLACEHOLDER, propertyMap );
        *   propertyMap["placeholderFontStyle"] = fontStyleMap;
        *
        *   field.SetProperty( DevelTextField::Property::PLACEHOLDER, propertyMap );
index 1e4d168..e763f2c 100644 (file)
@@ -674,7 +674,7 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P
           const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
 
           const std::string& text = value.Get< std::string >();
           DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor::OnPropertySet %p PLACEHOLDER_TEXT %s\n", impl.mController.Get(), text.c_str() );
 
-          impl.mController->SetPlaceholderText( text );
+          impl.mController->SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
         }
         break;
       }
         }
         break;
       }
@@ -1060,7 +1060,7 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind
         if( impl.mController )
         {
           std::string text;
         if( impl.mController )
         {
           std::string text;
-          impl.mController->GetPlaceholderText( text );
+          impl.mController->GetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
           value = text;
         }
         break;
           value = text;
         }
         break;
index 532afed..fef0f70 100644 (file)
@@ -71,7 +71,6 @@ EventData::EventData( DecoratorPtr decorator )
 : mDecorator( decorator ),
   mImfManager(),
   mPlaceholderFont( NULL ),
 : mDecorator( decorator ),
   mImfManager(),
   mPlaceholderFont( NULL ),
-  mPlaceholderText(),
   mPlaceholderTextActive(),
   mPlaceholderTextInactive(),
   mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ),
   mPlaceholderTextActive(),
   mPlaceholderTextInactive(),
   mPlaceholderTextColor( 0.8f, 0.8f, 0.8f, 0.8f ),
index f48ce13..054f4a7 100644 (file)
@@ -106,7 +106,6 @@ struct EventData
   DecoratorPtr       mDecorator;               ///< Pointer to the decorator.
   ImfManager         mImfManager;              ///< The Input Method Framework Manager.
   FontDefaults*      mPlaceholderFont;         ///< The placeholder default font.
   DecoratorPtr       mDecorator;               ///< Pointer to the decorator.
   ImfManager         mImfManager;              ///< The Input Method Framework Manager.
   FontDefaults*      mPlaceholderFont;         ///< The placeholder default font.
-  std::string        mPlaceholderText;         ///< The text to display when the TextField is empty.
   std::string        mPlaceholderTextActive;   ///< The text to display when the TextField is empty with key-input focus.
   std::string        mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
   Vector4            mPlaceholderTextColor;    ///< The in/active placeholder text color.
   std::string        mPlaceholderTextActive;   ///< The text to display when the TextField is empty with key-input focus.
   std::string        mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
   Vector4            mPlaceholderTextColor;    ///< The in/active placeholder text color.
@@ -387,9 +386,10 @@ struct Controller::Impl
    */
   bool IsPlaceholderAvailable() const
   {
    */
   bool IsPlaceholderAvailable() const
   {
-    return ( mEventData && ( !mEventData->mPlaceholderText.empty() ||
-                             !mEventData->mPlaceholderTextInactive.empty() ||
-                             !mEventData->mPlaceholderTextActive.empty() ) );
+    return ( mEventData &&
+             ( !mEventData->mPlaceholderTextInactive.empty() ||
+               !mEventData->mPlaceholderTextActive.empty() )
+           );
   }
 
   bool IsShowingPlaceholderText() const
   }
 
   bool IsShowingPlaceholderText() const
@@ -402,8 +402,7 @@ struct Controller::Impl
    */
   bool IsFocusedPlaceholderAvailable() const
   {
    */
   bool IsFocusedPlaceholderAvailable() const
   {
-    return ( mEventData && ( !mEventData->mPlaceholderTextActive.empty() ||
-                             !mEventData->mPlaceholderText.empty() ) );
+    return ( mEventData && !mEventData->mPlaceholderTextActive.empty() );
   }
 
   bool IsShowingRealText() const
   }
 
   bool IsShowingRealText() const
index a0daf14..fbd26bf 100644 (file)
@@ -48,6 +48,7 @@ const float MAX_FLOAT = std::numeric_limits<float>::max();
 const std::string EMPTY_STRING("");
 
 const char * const PLACEHOLDER_TEXT = "placeholderText";
 const std::string EMPTY_STRING("");
 
 const char * const PLACEHOLDER_TEXT = "placeholderText";
+const char * const PLACEHOLDER_TEXT_FOCUSED = "placeholderTextFocused";
 const char * const PLACEHOLDER_COLOR = "placeholderColor";
 const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily";
 const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
 const char * const PLACEHOLDER_COLOR = "placeholderColor";
 const char * const PLACEHOLDER_FONT_FAMILY = "placeholderFontFamily";
 const char * const PLACEHOLDER_FONT_STYLE = "placeholderFontStyle";
@@ -531,22 +532,6 @@ void Controller::GetText( std::string& text ) const
   }
 }
 
   }
 }
 
-void Controller::SetPlaceholderText( const std::string& text )
-{
-  if( NULL != mImpl->mEventData )
-  {
-    mImpl->mEventData->mPlaceholderText = text;
-
-    // Update placeholder if there is no text
-    if( mImpl->IsShowingPlaceholderText() ||
-        ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) )
-    {
-      ShowPlaceholderText();
-    }
-  }
-}
-
-// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field
 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
 {
   if( NULL != mImpl->mEventData )
 void Controller::SetPlaceholderText( PlaceholderType type, const std::string& text )
 {
   if( NULL != mImpl->mEventData )
@@ -569,15 +554,6 @@ void Controller::SetPlaceholderText( PlaceholderType type, const std::string& te
   }
 }
 
   }
 }
 
-void Controller::GetPlaceholderText( std::string& text ) const
-{
-  if( NULL != mImpl->mEventData )
-  {
-    text = mImpl->mEventData->mPlaceholderText;
-  }
-}
-
-// This is overloading function for PLACEHOLDER_TEXT_FOCUSED in text-field
 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
 {
   if( NULL != mImpl->mEventData )
 void Controller::GetPlaceholderText( PlaceholderType type, std::string& text ) const
 {
   if( NULL != mImpl->mEventData )
@@ -1918,7 +1894,13 @@ void Controller::SetPlaceholderProperty( const Property::Map& map )
     {
       std::string text = "";
       value.Get( text );
     {
       std::string text = "";
       value.Get( text );
-      SetPlaceholderText( text );
+      SetPlaceholderText( Controller::PLACEHOLDER_TYPE_INACTIVE, text );
+    }
+    else if( key == PLACEHOLDER_TEXT_FOCUSED )
+    {
+      std::string text = "";
+      value.Get( text );
+      SetPlaceholderText( Controller::PLACEHOLDER_TYPE_ACTIVE, text );
     }
     else if( key == PLACEHOLDER_COLOR )
     {
     }
     else if( key == PLACEHOLDER_COLOR )
     {
@@ -1964,7 +1946,15 @@ void Controller::GetPlaceholderProperty( Property::Map& map )
 {
   if( NULL != mImpl->mEventData )
   {
 {
   if( NULL != mImpl->mEventData )
   {
-    map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderText;
+    if( !mImpl->mEventData->mPlaceholderTextActive.empty() )
+    {
+      map[ PLACEHOLDER_TEXT_FOCUSED ] = mImpl->mEventData->mPlaceholderTextActive;
+    }
+    if( !mImpl->mEventData->mPlaceholderTextInactive.empty() )
+    {
+      map[ PLACEHOLDER_TEXT ] = mImpl->mEventData->mPlaceholderTextInactive;
+    }
+
     map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
     map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily();
 
     map[ PLACEHOLDER_COLOR ] = mImpl->mEventData->mPlaceholderTextColor;
     map[ PLACEHOLDER_FONT_FAMILY ] = GetPlaceholderFontFamily();
 
@@ -3554,27 +3544,17 @@ void Controller::ShowPlaceholderText()
     const char* text( NULL );
     size_t size( 0 );
 
     const char* text( NULL );
     size_t size( 0 );
 
-    if( !mImpl->mEventData->mPlaceholderTextActive.empty() || !mImpl->mEventData->mPlaceholderTextInactive.empty() )
+    // TODO - Switch Placeholder text when changing state
+    if( ( EventData::INACTIVE != mImpl->mEventData->mState ) &&
+        ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) )
     {
     {
-      if( ( EventData::INACTIVE != mImpl->mEventData->mState ) &&
-          ( 0u != mImpl->mEventData->mPlaceholderTextActive.c_str() ) )
-      {
-        text = mImpl->mEventData->mPlaceholderTextActive.c_str();
-        size = mImpl->mEventData->mPlaceholderTextActive.size();
-      }
-      else
-      {
-        text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
-        size = mImpl->mEventData->mPlaceholderTextInactive.size();
-      }
+      text = mImpl->mEventData->mPlaceholderTextActive.c_str();
+      size = mImpl->mEventData->mPlaceholderTextActive.size();
     }
     else
     {
     }
     else
     {
-      if( 0u != mImpl->mEventData->mPlaceholderText.c_str() )
-      {
-        text = mImpl->mEventData->mPlaceholderText.c_str();
-        size = mImpl->mEventData->mPlaceholderText.size();
-      }
+      text = mImpl->mEventData->mPlaceholderTextInactive.c_str();
+      size = mImpl->mEventData->mPlaceholderTextInactive.size();
     }
 
     mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
     }
 
     mImpl->mTextUpdateInfo.mCharacterIndex = 0u;
index 9c80fc7..3d7639d 100644 (file)
@@ -466,13 +466,6 @@ public: // Update.
   /**
    * @brief Replaces any placeholder text previously set.
    *
   /**
    * @brief Replaces any placeholder text previously set.
    *
-   * @param[in] text A string of UTF-8 characters.
-   */
-  void SetPlaceholderText( const std::string& text );
-
-  /**
-   * @brief Replaces any placeholder text previously set.
-   *
    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
    * @param[in] text A string of UTF-8 characters.
    */
    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
    * @param[in] text A string of UTF-8 characters.
    */
@@ -481,13 +474,6 @@ public: // Update.
   /**
    * @brief Retrieve any placeholder text previously set.
    *
   /**
    * @brief Retrieve any placeholder text previously set.
    *
-   * @param[out] A string of UTF-8 characters.
-   */
-  void GetPlaceholderText( std::string& text ) const;
-
-  /**
-   * @brief Retrieve any placeholder text previously set.
-   *
    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
    * @param[out] A string of UTF-8 characters.
    */
    * @param[in] type Different placeholder-text can be shown when the control is active/inactive.
    * @param[out] A string of UTF-8 characters.
    */