Add 'markup-enabled' property to TextView 05/20305/1
authorJavon Prince <javon.prince@samsung.com>
Thu, 24 Apr 2014 10:47:06 +0000 (11:47 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Thu, 1 May 2014 15:01:35 +0000 (16:01 +0100)
[Issue#] (N/A)

[Problem] Unable to enable markup-processing in JSON file

[Cause] SetMarkupProcessingEnabled() is a function not a property

[Solution] Wrap SetMarkupProcessingEnabled() with a new property

Change-Id: Idf1b00df0dba166ad13a3f831c2ea8d7e91c0009
Signed-off-by: David Steele <david.steele@partner.samsung.com>
capi/dali-toolkit/public-api/controls/text-view/text-view.h
dali-toolkit/internal/controls/text-view/text-view-impl.cpp
dali-toolkit/internal/controls/text-view/text-view-impl.h

index 1147c424a4328d8125b2874e68ca2c60eb5fc9b4..6e671418ab810df33e8d324f2f51641dc36e1ab0 100644 (file)
@@ -103,6 +103,9 @@ public:
   // Signal Names
   static const char* const SIGNAL_TEXT_SCROLLED; ///< Signal emitted when the scroll position changes. @see SignalScrolled()
 
+  // Properties
+  static const Property::Index PROPERTY_MARKUP_ENABLED; ///< name "markup-enabled", @see SetMarkupProcessingEnabled(), type BOOLEAN
+
   /**
    * @brief Structure used to retrieve Layout info per character.
    */
index 8082ce8efa716e83222b042d2b50fce5436fe2a4..37ce6281f14f3ec82f6c4abf572be1df22a4e21a 100644 (file)
@@ -32,6 +32,8 @@ namespace Dali
 namespace Toolkit
 {
 
+const Property::Index TextView::PROPERTY_MARKUP_ENABLED( Internal::TextView::TEXTVIEW_PROPERTY_START_INDEX );
+
 namespace Internal
 {
 
@@ -64,6 +66,8 @@ TypeRegistration typeRegistration( typeid(Toolkit::TextView), typeid(Toolkit::Co
 
 SignalConnectorType signalConnector1( typeRegistration, Toolkit::TextView::SIGNAL_TEXT_SCROLLED , &TextView::DoConnectSignal );
 
+PropertyRegistration property1( typeRegistration, "markup-enabled", Toolkit::TextView::PROPERTY_MARKUP_ENABLED, Property::BOOLEAN, &TextView::SetProperty, &TextView::GetProperty );
+
 /**
  * Whether the text-view-processor operation sets, inserts, replaces, removes text.
  *
@@ -2109,6 +2113,38 @@ void TextView::OnAlignmentPropertySet( Property::Index propertyIndex, Property::
   }
 }
 
+void TextView::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
+{
+  Toolkit::TextView textView = Toolkit::TextView::DownCast( Dali::BaseHandle( object ) );
+
+  if ( textView && ( index == Toolkit::TextView::PROPERTY_MARKUP_ENABLED ) )
+  {
+    Internal::TextView& textViewImpl( GetImpl( textView ) );
+    bool newValue( value.Get<bool>() );
+    textViewImpl.SetMarkupProcessingEnabled( newValue );
+    if( newValue )
+    {
+      const std::string& currentText( textViewImpl.GetText() );
+      if( ! currentText.empty() )
+      {
+        textViewImpl.SetText( currentText );
+      }
+    }
+  }
+}
+
+Property::Value TextView::GetProperty( BaseObject* object, Property::Index propertyIndex )
+{
+  Toolkit::TextView textView = Toolkit::TextView::DownCast( Dali::BaseHandle( object ) );
+
+  if ( textView && ( propertyIndex == Toolkit::TextView::PROPERTY_MARKUP_ENABLED ) )
+  {
+    return Property::Value( GetImpl( textView ).mMarkUpEnabled );
+  }
+
+  return Property::Value();
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 7493fcc8cc6142a8b977182de0c10592a717239f..72a8cf50122977989793aa14e0ab31df6f6531ce 100644 (file)
@@ -42,6 +42,13 @@ class TextView : public ControlImpl
 {
 public:
 
+  // Properties
+  enum
+  {
+    TEXTVIEW_PROPERTY_START_INDEX = ControlImpl::CONTROL_PROPERTY_END_INDEX + 1,
+    TEXTVIEW_PROPERTY_END_INDEX = TEXTVIEW_PROPERTY_START_INDEX + 1000 ///< Reserving 1000 property indices
+  };
+
   /**
    * Internal exceed policy with the valid combinations.
    */
@@ -333,6 +340,25 @@ public:
    */
   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
 
+  // Properties
+
+  /**
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
+   */
+  static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
+
+  /**
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
+   */
+  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+
+
 private: // From ControlImpl
 
   /**