From 1c41fb34f0fdef579ffd9590758e96dcb70e7003 Mon Sep 17 00:00:00 2001 From: Javon Prince Date: Thu, 24 Apr 2014 11:47:06 +0100 Subject: [PATCH] Add 'markup-enabled' property to TextView [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 --- .../public-api/controls/text-view/text-view.h | 3 ++ .../internal/controls/text-view/text-view-impl.cpp | 36 ++++++++++++++++++++++ .../internal/controls/text-view/text-view-impl.h | 26 ++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/capi/dali-toolkit/public-api/controls/text-view/text-view.h b/capi/dali-toolkit/public-api/controls/text-view/text-view.h index 1147c42..6e67141 100644 --- a/capi/dali-toolkit/public-api/controls/text-view/text-view.h +++ b/capi/dali-toolkit/public-api/controls/text-view/text-view.h @@ -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. */ diff --git a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp index 8082ce8..37ce628 100644 --- a/dali-toolkit/internal/controls/text-view/text-view-impl.cpp +++ b/dali-toolkit/internal/controls/text-view/text-view-impl.cpp @@ -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() ); + 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 diff --git a/dali-toolkit/internal/controls/text-view/text-view-impl.h b/dali-toolkit/internal/controls/text-view/text-view-impl.h index 7493fcc..72a8cf5 100644 --- a/dali-toolkit/internal/controls/text-view/text-view-impl.h +++ b/dali-toolkit/internal/controls/text-view/text-view-impl.h @@ -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 /** -- 2.7.4